package com.afsadmedia.pregnancy;

import java.util.ArrayList;
import java.util.List;

import com.actionbarsherlock.app.SherlockActivity;



import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class Listview extends SherlockActivity{
	
	List<ListItem> rowItems;
	 CustomListViewAdapter adapter;
	 
	 ArrayList<String> datalist;
	ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
	// TODO Auto-generated method stub
	super.onCreate(savedInstanceState);
	setContentView(R.layout.listview);
	
	
	
	
	datalist = new ArrayList<String>();
	
	datalist.add("Week by Week Baby Tracker");
	datalist.add("Weight Management/Traking");
	datalist.add("Symptoms");
	datalist.add("Notes");
	datalist.add("Remainders");
	datalist.add("Measurements");
	

	rowItems = new ArrayList<ListItem>();
	for (int i = 0; i < datalist.size(); i++) {

		ListItem item1 = new ListItem(datalist.get(i), null);

		rowItems.add(item1);
	}

	listView = (ListView) findViewById(R.id.listView_list);
	
	adapter = new CustomListViewAdapter(getApplicationContext(), R.layout.listitem,
			rowItems);
	listView.setAdapter(adapter);
	
	
	listView.setOnItemClickListener(new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View view, int position,
				long arg3) {
			// TODO Auto-generated method stub
			
			if(position == 0){
				
				Intent i = new Intent(Listview.this,WeekbyWeekTracker.class);
				startActivity(i);
			}else if(position == 1){
				Intent i = new Intent(Listview.this,WeightManagement.class);
				startActivity(i);
				
			}else if(position == 2){
				Intent i = new Intent(Listview.this,Symptoms.class);
				startActivity(i);
				
			}
			
			else if(position == 3){
				Intent i = new Intent(Listview.this,Notes.class);
				startActivity(i);
				
			}
			
			else if(position == 3){
				Intent i = new Intent(Listview.this,Notes.class);
				startActivity(i);
				
			}else if(position == 5){
				Intent i = new Intent(Listview.this,Measurement.class);
				startActivity(i);
				
			}
			
			
		}
	});
	
}



public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
	 
	getSupportActionBar().setBackgroundDrawable(
			getResources().getDrawable(R.drawable.actionbar_background)); 
	getSupportActionBar().setTitle("Favorite");
	getSupportActionBar().setDisplayHomeAsUpEnabled(true); 
	getSupportActionBar().setHomeButtonEnabled(true);
    return super.onCreateOptionsMenu(menu);

}

public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
    switch(item.getItemId()){
    
    case android.R.id.home:
			Intent in=new Intent(Listview.this,HomeActivity.class);
			in.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(in);
    	
       return true;
 
    default:
        return false;
    }
}


}
